package com.ruoyi.littleRedBook.tools;

import java.security.SecureRandom;

public class SmsCodeUtils {
    /**
     * 验证码工具类，接受参数为数字长度
     * @param length
     * @return
     */
    public static String generateNumericCode(int length) {
        SecureRandom random = new SecureRandom();
        StringBuilder code = new StringBuilder();
        for (int i = 0; i < length; i++) {
            code.append(random.nextInt(10)); // 生成 0-9 的数字
        }
        return code.toString();
    }
}
